package com.cn.jdia.dc.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.jdia.dc.context.SpringContextUtils;
import com.cn.jdia.dc.model.Backupconfig;
import com.cn.jdia.dc.service.IBackupconfigService;

@Controller
@RequestMapping("/backconfig")
public class BackupConfigController {

	@Resource
	private IBackupconfigService backupconfigService;

	@RequestMapping(value = "/insert")
	@ResponseBody
	public String dbconfigInsert(@RequestParam("project") String project, @RequestParam("localpath") String localpath,
			@RequestParam("sourceip") String sourceip, @RequestParam("sourcepath") String sourcepath,
			@RequestParam("namerule") String namerule, @RequestParam("clean") String clean) {
		int ret = -1;
		// System.out.println(project + localpath + sourceip + sourcepath +
		// namerule + clean);

		Backupconfig backupConfig = new Backupconfig();
		backupConfig.setProject(project);
		backupConfig.setPath(localpath);
		backupConfig.setSource(sourceip);
		backupConfig.setSourcepath(sourcepath);
		backupConfig.setNamerule(namerule);
		backupConfig.setExpired(Integer.parseInt(clean));

		backupconfigService = (IBackupconfigService) SpringContextUtils.getContext().getBean("backupconfigService");
		ret = backupconfigService.insertBackupConfig(backupConfig);

		return ret + "";
	}

}
